/*
 * @Author: Zhouhai 497675647@qq.com
 * @Date: 2022-10-08 11:44:43
 * @LastEditors: Zhouhai 497675647@qq.com
 * @LastEditTime: 2022-10-08 15:27:23
 */
import { CustomFormConfig, TNumber } from "@/type.d/formItems";
import { ProFormDigit } from "@ant-design/pro-form"

export const RenderNumber: (itemconfig: CustomFormConfig, disabled: boolean) => JSX.Element = (itemconfig, disabled) => {
    const placeholder = disabled ? "" : (itemconfig.placeholder || `请输入${itemconfig.title}`);
    const config: TNumber = itemconfig.config as TNumber;
    const precision = config?.precision  === undefined ?  2 : config?.precision
    
    return <ProFormDigit
        key={itemconfig.fieldId}
        width="md"
        colProps={{ md: 8, xl: 6 }}
        name={itemconfig.fieldId}
        label={itemconfig.title}
        tooltip={config?.tooltip}
        placeholder={placeholder}
        fieldProps={{ precision }}
    />
}